#region Using directives

using System;

#endregion

namespace Hanoi.Utils.Profiles
{
    public class ProfileBase
    {
        public ProfileBase()
        {
            
        }


        /// <summary>
        /// Get a Random number base on the time.
        /// </summary>
        /// <param name="max">The modulus.</param>
        public int GetRandomNumber(int mod, int cannotBe)
        {
            if (mod < 2)
                throw new NotSupportedException("The modulus must be 2 or greater provided that the function just works with integers and has exclusion.");

            DateTime d = DateTime.Now;
            int t = GenerateRandom(mod, ref d);
            if (t == cannotBe)
            {
                System.Threading.Thread.Sleep(300 + GetRandomNumber(400));
                return GetRandomNumber(mod, cannotBe);
            }
            else
                return t;
        }

        private static int GenerateRandom(int mod, ref DateTime d)
        {
            return (d.Millisecond + d.Second + d.Minute + d.Hour) % mod;
        }

        public int GetRandomNumber(int mod)
        {
            return GetRandomNumber(mod, -1);
        }

        public int CalculateMoves(int size)
        {
            return Convert.ToInt32(Math.Pow(2, size)) - 1;
        }
    }
}
